/**
 * @author Caius
 * @description
 * @version 1.0
 * @since Created in 2025-01-02
 */

package com.itsense.stock.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfiguration {
    @Bean
    public Docket buildDocket(){
        //构建在线API概要对象
       return new Docket(DocumentationType.SWAGGER_2)
               .apiInfo(buildApiInfo())
               .select()
               //要扫描的API(controller)基础包
               .apis(RequestHandlerSelectors.basePackage("com.itsense.stock.controller"))
               .paths(PathSelectors.any())
               .build();
    }
    private ApiInfo buildApiInfo() {
        //网站联系方式
        Contact contact = new Contact("程序员caius","http://www.itcaius.com","sense1906@outlook.com");
        return new ApiInfoBuilder()
                .title("today_stock API doc") //文档标题
                .description("开发接口需求API文档") //文档描述信息
                .contact(contact) //站点联系人相关信息
                .version("1.0.0") //文档版本
                .build();
    }
}
